﻿using Ceremony.API.Model;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Ceremony.API.Infrastructure.EntityConfigurations
{
    public class CommentEntityTypeConfiguration
        : IEntityTypeConfiguration<Comment>
    {
        public void Configure(EntityTypeBuilder<Comment> builder)
        {
            builder.ToTable("Comment");

            builder.HasKey(ci => ci.Id);

            builder.Property(ci => ci.Id)
               .UseHiLo("comment_hilo")
               .IsRequired();

            builder.Property(cb => cb.WechatMomentId)
                .IsRequired(true);
            builder.Property(cb => cb.CommentType)
               .IsRequired(true);
            builder.Property(cb => cb.FromUserId)
                .IsRequired(true);
            builder.Property(cb => cb.ToUserId)
               .IsRequired(true);
            builder.Property(cb => cb.CreateTime)
               .IsRequired(true);
            builder.Property(cb => cb.IsRemove)
                .IsRequired(true);
            builder.Property(cb => cb.RemoveTime)
                .IsRequired(false);
            builder.Property(cb => cb.CommentMessage)
               .IsRequired(false);
        }
    }
}
